package com.heima.minio;


import com.heima.file.service.FileStorageService;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.FileInputStream;
import java.io.FileNotFoundException;


@SpringBootTest(classes = MinioApplication.class)
@RunWith(SpringRunner.class)
public class MinIOTest2 {

    @Autowired
    private FileStorageService fileStorageService;


    /**
     * 上传html文件到minio
     * @throws Exception
     */
    @Test
    public void testUpload() throws Exception {
        FileInputStream fileInputStream = new FileInputStream("d:\\list2.html");
        String path = fileStorageService.uploadHtmlFile("", "new.html", fileInputStream);
        System.out.println(path);
    }

    /**
     * 上传文件
     * @throws FileNotFoundException
     */
    @Test
    public void testUploadFile() throws FileNotFoundException {
        FileInputStream fileInputStream= new FileInputStream("C:\\Users\\Administrator\\Desktop\\微信图片_20220725181031.jpg");
        String path = fileStorageService.uploadImgFile("", "测试图片.jpg", fileInputStream);
        System.out.println(path);

    }

    /**
     * 删除minio中的文件
     */
    @Test
    public void testDel(){

        fileStorageService.delete("http://124.220.92.69:9000/minio57/2022/08/27/mylist.html");
    }



}